/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package FileStructure;

import java.util.ArrayList;

/**
 *
 * @author user
 */
public class Response {
    public String failure_reason;
    public String warning_message;
    public int interval;
    public int complete;
    public int incomplete;
    public ArrayList<IPPort> peers;

    public Response(){
        this.failure_reason = "";
        this.warning_message = "No warnings";
        this.interval = 0;
        this.complete = 0;
        this.incomplete = 0;
        peers = new ArrayList<IPPort>();
    }

    public Response(String f, String w, int in, int c, int inc){
        this.failure_reason = f;
        this.warning_message = w;
        this.interval = in;
        this.complete = c;
        this.incomplete = inc;
        peers = null;
    }

    public void addPeer(String IP, int port){
        IPPort ip = new IPPort(IP,port);
        peers.add(ip);
    }

    public void removeOnePeer(int port){
        //cari idx
        int idx = 0;
        for (int i=0; i<peers.size(); i++){
            if (peers.get(i).Port == port){
                idx = i;
            }
        }
        peers.remove(idx);
    }


    public class IPPort{
        public String IP;
        public int Port;

        public IPPort(String i, int p){
            this.IP = i;
            this.Port = p;
        }
    }
}
